home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d16
/
nodee1.arc
/
SOURCE.ARC
/
NODCHILD.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1991-09-01
|
7KB
|
331 lines
/*
NODCHILD.CPP
code for child windows for the NoD program
*/
#if !defined( __WINDOWS_H )
#include <Windows.h>
#endif // __WINDOWS_H
#if !defined( __NODCHILD_H )
#include "Nodchild.h"
#endif
#ifndef __NOD1_H
#include "nod1.h"
#endif
#ifndef __STRING_H
#include <string.h>
#endif
/*------------------------------------------------ Child Classes
*/
void DBox::create(HWND hA)
{
HDC hdc;
TEXTMETRIC tm;
int cxChar,cyChar;
char *text="ICK!";
hParent=hA;
hdc=GetDC(hParent);
SelectObject(hdc,GetStockObject(SYSTEM_FIXED_FONT));
GetTextMetrics(hdc,&tm);
cxChar=tm.tmAveCharWidth;
cyChar=tm.tmHeight+tm.tmExternalLeading;
ReleaseDC(hParent,hdc);
hwndChild=CreateWindow
("button",text,WS_CHILD|WS_VISIBLE|SS_CENTER,
42*cxChar,5*cyChar,
(strlen(text)+2)*cxChar,2*7*cyChar/4,
hParent,MYCW_ICKBUTTON,WinBase::hInst,NULL);
unset();
}
void DBox::set(void)
{
ShowWindow(hwndChild,SW_SHOWNORMAL);
EnableWindow(hwndChild,TRUE);
}
void DBox::unset(void)
{
ShowWindow(hwndChild,SW_HIDE);
EnableWindow(hwndChild,FALSE);
}
/*-----------------------------------------------
*/
void GoButton::create(HWND hA)
{
HDC hdc;
TEXTMETRIC tm;
int cxChar,cyChar;
text="Take It Out!";
hParent=hA;
hdc=GetDC(hParent);
SelectObject(hdc,GetStockObject(SYSTEM_FIXED_FONT));
GetTextMetrics(hdc,&tm);
cxChar=tm.tmAveCharWidth;
cyChar=tm.tmHeight+tm.tmExternalLeading;
ReleaseDC(hParent,hdc);
hwndChild=CreateWindow
("button",text,WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON,
40*cxChar,10*cyChar,
(strlen(text)+2)*cxChar,7*cyChar/4,
hParent,MYCW_GOBUTTON,WinBase::hInst,NULL);
}
/*------------------------------------------------------------*/
void FirstLine::create(HWND hA)
{
HDC hdc;
TEXTMETRIC tm;
int cxChar,cyChar;
text="nothing yet";
hParent=hA;
hdc=GetDC(hParent);
SelectObject(hdc,GetStockObject(SYSTEM_FIXED_FONT));
GetTextMetrics(hdc,&tm);
cxChar=tm.tmAveCharWidth;
cyChar=tm.tmHeight+tm.tmExternalLeading;
ReleaseDC(hParent,hdc);
hwndChild=CreateWindow
("static",text,WS_CHILDWINDOW|WS_VISIBLE|SS_LEFT,
10*cxChar,2*cyChar,
(60+2)*cxChar,7*cyChar/4,
hParent,MYCW_FIRSTLINE,WinBase::hInst,NULL);
}
void FirstLine::set(char* a)
{
SetWindowText(hwndChild,(LPSTR) a);
}
/*--------------------------------------------------------------------*/
void FileList::create(HWND hA)
{
HDC hdc;
TEXTMETRIC tm;
int cxChar,cyChar;
hParent=hA;
if (strlen(szMask)==0)
mask("*.*");
hdc=GetDC(hParent);
SelectObject(hdc,GetStockObject(SYSTEM_FIXED_FONT));
GetTextMetrics(hdc,&tm);
cxChar=tm.tmAveCharWidth;
cyChar=tm.tmHeight;
ReleaseDC(hParent,hdc);
hwndChild=CreateWindow
("listbox",NULL,WS_CHILDWINDOW|WS_VISIBLE|LBS_STANDARD,
2*cxChar,5*cyChar,
13*cxChar+GetSystemMetrics(SM_CXVSCROLL),15*cyChar,
hParent,MYCW_FILELIST,WinBase::hInst,NULL);
reset();
bValidFile=FALSE;
}
DWORD FileList::send(WORD msg,WORD wParam,long lParam)
{
return SendMessage(hwndChild,msg,wParam,lParam);
}
void FileList::mask(char *a)
{
strcpy(szMask,a);
}
BOOL FileList::fileClick(void)
{
int index;
char szBuffer[MAXPATH];
OFSTRUCT ofs;
if (LB_ERR == (index= (WORD) send(LB_GETCURSEL,0,0L)) )
return FALSE;
send(LB_GETTEXT,index,(LONG) (char far *) szBuffer);
if (-1 != OpenFile(szBuffer,&ofs,OF_EXIST|OF_READ))
{
bValidFile=TRUE;
getcwd(szFileName,MAXPATH);
if (szBuffer[strlen(szFileName)-1] != '\\')
strcat(szFileName,"\\");
strcat(szFileName,szBuffer);
}
return TRUE;
}
BOOL FileList::validFile(void)
{
return bValidFile;
}
char* FileList::getFile(void)
{
return szFileName;
}
void FileList::reset(void)
{
send(LB_RESETCONTENT,0,0L);
send(LB_DIR,0x0,(LONG)(LPSTR) szMask);
}
/*--------------------------------------------------------------------
DirList code
*/
void DirList::create(HWND hA)
{
HDC hdc;
TEXTMETRIC tm;
int cxChar,cyChar;
hParent=hA;
hdc=GetDC(hParent);
SelectObject(hdc,GetStockObject(SYSTEM_FIXED_FONT));
GetTextMetrics(hdc,&tm);
cxChar=tm.tmAveCharWidth;
cyChar=tm.tmHeight;
ReleaseDC(hParent,hdc);
hwndChild=CreateWindow
("listbox",NULL,WS_CHILDWINDOW|WS_VISIBLE|LBS_STANDARD,
17*cxChar+GetSystemMetrics(SM_CXVSCROLL),8*cyChar,
13*cxChar+GetSystemMetrics(SM_CXVSCROLL),12*cyChar,
hParent,MYCW_DIRLIST,WinBase::hInst,NULL);
reset();
/* since the object creates this box and keeps the handle
control is not allowed outside */
hDirField=CreateWindow
("static"," ",WS_CHILDWINDOW|WS_VISIBLE|SS_LEFT,
17*cxChar+GetSystemMetrics(SM_CXVSCROLL),6*cyChar,
(30+2)*cxChar,7*cyChar/4,
hParent,MYCW_DIRFIELD,WinBase::hInst,NULL);
getcwd(szDirName,MAXPATH);
SetWindowText(hDirField,szDirName);
}
DWORD DirList::send(WORD msg,WORD wParam,long lParam)
{
return SendMessage(hwndChild,msg,wParam,lParam);
}
BOOL DirList::dirClick(void)
{
int index;
char szBuffer[MAXPATH];
if (LB_ERR == (index= (WORD) send(LB_GETCURSEL,0,0L)) )
return FALSE;
send(LB_GETTEXT,index,(LONG) (char far *) szBuffer);
if (strstr(szBuffer,"[-") != 0)
{
setdisk((int) (szBuffer[2]) - 'a');
}
else
{
szBuffer[strlen(szBuffer)-1] = '\0';
chdir(szBuffer+1);
}
getcwd(szDirName,MAXPATH);
reset();
SetWindowText(hDirField,szDirName);
return TRUE;
}
void DirList::reset(void)
{
send(LB_RESETCONTENT,0,0L);
send(LB_DIR,0xc010,(LONG)(LPSTR) "*.*");
}
/*---------------------------------------------------------------
FileFinder code
-------------------------------------------------------------*/
void FileFinder::create(HWND hParent)
{
HDC hdc;
TEXTMETRIC tm;
int cxChar,cyChar;
hdc=GetDC(hParent);
SelectObject(hdc,GetStockObject(SYSTEM_FIXED_FONT));
GetTextMetrics(hdc,&tm);
cxChar=tm.tmAveCharWidth;
cyChar=tm.tmHeight;
ReleaseDC(hParent,hdc);
FileList::create(hParent);
DirList::create(hParent);
}
void FileFinder::reset(void)
{
FileList::reset();
DirList::reset();
}
BOOL FileFinder::dirClick()
{
BOOL i;
i=DirList::dirClick();
FileList::reset();
return i;
}
void FileFinder::send(void)
{
}